package wdn.shared;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;


@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Guests {
		@PrimaryKey
		@Persistent (valueStrategy = IdGeneratorStrategy.IDENTITY) private Key key;
		@Persistent	private String name;
		@Persistent	private String email;
		@Persistent	private int gtotal;
		@Persistent	private String hash;
		@Persistent	private boolean Sep4;		
		@Persistent	private boolean Sep12;		
		
		public Guests (String name, String email)
		{
			try {
				MessageDigest digest = MessageDigest.getInstance("MD5");
				digest.update(email.getBytes());
	
				this.name = name;
				this.email = email;
				this.setGtotal(1);
				this.hash = digest.digest().toString();
				this.Sep4 = false;
				this.Sep12 = false;
			} catch (NoSuchAlgorithmException e) {
			}
		}
		
		public Key getKey() {
			return key;
		}
		
		public String getName () {
			return this.name;
		}
		
		public String getEmail () {
			return this.email;
		}
		
		public String getHash () {
			return this.hash;
		}
		
		public boolean getSep4 () {
			return this.Sep4;
		}

		public boolean getSep12 () {
			return this.Sep12;
		}

		public void setGtotal(int gtotal) {
			this.gtotal = gtotal;
		}

		public int getGtotal() {
			return gtotal;
		}

}
